package com.szq.netty.server;

import com.szq.netty.codec.MyDecoder;
import com.szq.netty.codec.MyEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * @ClassName: MyChannelInitializer
 * @Description:
 * @Author: szq
 * @Date: 2021-11-10 16:40:13
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) {
        //自定义解码器
        socketChannel.pipeline().addLast(new MyDecoder());
        //自定义编码器
        socketChannel.pipeline().addLast(new MyEncoder());
        //在管道中添加我们自己的接收数据实现方法
        socketChannel.pipeline().addLast(new MyServerHandler());
    }
}
